        TITL DAI FIRMWARE DAD4-DB6E  V1.1
        ORG   :DAD4
*
*
*
*  ================
*** PRINT ROUTINES ***
*  ================
*
*
*****************
* PRINT MESSAGE *
*****************
*
* Prints a message, which may include internal
* references to other submessages.
*
* Entry: Pointer to message in HL.
* Exit:  Pointer after string in HL. Other
*        registers preserved.
*
* Message format: A series of bytes:
*        00    End of string.
*        01-7F Printed character.
*        >= 80 bit 14 set:
*              bits 0-13 are offset in program of
*              a message (char. terminated by a 0).
*              bit 14 unset:
*              bits 0-13 are offset in program of
*              a string (1 byte length + char.).
*
PMSG    PUSH  PSW
PMS10   MOV   A,M       Get character
        INX   H         Points to next char.
PMS15   ORA   A         Check char.
        JZ    :DAE4     If end message
        JM    :DAE6     If submessage reference
        CALL  :DD60     Print character in A
        JMP   :DAD5     Next
*
PMS20   POP   PSW       End message
        RET
 REM
* Submessage reference:
 REM
PMS30   CPI   :C0
        PUSH  H
        MOV   L,M       Lobyte in L
        JC    :DAF6     If reference to string
        MOV   H,A       BASE is at location C000
        CALL  :DAD4     Print submessage
PMS35   POP   H
        INX   H
        JMP   :DAD5     Next character
 REM
* String reference:
 REM
PMS40   ADI   :40       (BASE SHR 8) - #80
        MOV   H,A       Hibyte in H
        CALL  :DB32     Print substring pntd by HL
        JMP   :DAF1     Next character
*
*
********************************************
* PRINT MESSAGE POINTED TO BY NEXT 2 BYTES *
********************************************
*
* Entry: Top of stack points to the address where
*        the address of the message can be found.
* Exit:  AFBCDEHL preserved.
*        Returnaddress on stack.
*
PMSGR   XTHL            Get pntr from stack
        PUSH  D
        MOV   E,M       Get lobyte address
        INX   H
        MOV   D,M       Get hibyte address
        INX   H
        XCHG            Addr message in HL
        CALL  :DAD4     Print message
        XCHG            HL pnts after message pntr
        POP   D
        XTHL            Restore stack
        RET
*
************************
* CURSOR TO NEXT FIELD *
************************
*
* Part of 'run PRINT' (0E2B3).
* Moves the cursor to a new number output field.
* The field size is 12 character positions; field
* positions: 0,12,24,36,48.
*
PSKP    RST   5         Ask cursor position
        DATA  :0C       and size character screen
        MOV   A,L       X-coord in L
        CPI   :30       Already past last field?
        JNC   :DB27     Then print car.ret, abort
PSK10   SUI   :0C       ) Minus 12 untill underflow
        JNC   :DB15     )
PSK15   CMA             Restore pos. value
        INR   A
 REM
* Entry from 'SFC' function:
 REM
PSK20   MOV   D,A       Store nr of spaces required
PSK30   MVI   A,:20
        CALL  :DD60     Print space
        DCR   D         Ready?
        JNZ   :DB1D     Next space if not
        RET
*
PSK40   JMP   :DD5E     Print car.ret
*
********************
* CURSOR TO TAB(8) *
********************
*
* Part of 'List current line' (0ECB3).
* Moves cursor to column 8 after linenumber.
*
* Exit: BC preserved. AFDEHL corrupted.
*
 REM
*SCTAB
PTAB    RST   5         Ask cursor position and
        DATA  :0C       size character screen
        MOV   A,L       X-coord after linenr in A
        SUI   :06       Tab must be 8
        JMP   :DB1A     Print additional spaces
*
****************
* PRINT STRING *
****************
*
* Prints a string of characters pointed to by HL.
*
* Entry: HL points to string.
* Exit:  HL points after string.
*        Other registers preserved.
*
* String format:
*        1 byte length (0 = no data).
*        N bytes data.
*
*SCSTR
PSTR    PUSH  PSW
        PUSH  B
        MOV   B,M       String length in B
PST10   INX   H
PST20   MOV   A,B       Get length
        SUI   :01       Minus 1
        MOV   B,A       Nr. char still to be printed
        MOV   A,M       Get char
        CNC   :D695     Print character if not ready
        JNC   :DB35     Next one if not ready
        POP   B
        POP   PSW
        RET
*
************************
* PRINT STRING MESSAGE *
************************
*
* Prints a string of characters, pointed to by
* HL, length in A.
*
* Entry: HL: Points to string.
*        A:  Number of characters.
* Exit:  HL: Points after string.
*        AFBCDE preserved.
*
*SCSTM
PSTRM   PUSH  PSW
        PUSH  B
        MOV   B,A       String length in B
        JMP   :DB36     Print string
*
**********************
* PRINT A HEX NUMBER *
**********************
*
* Converts MACC to hex in DECBUF and print it.
*
* Exit: HL points after string in DECBUF.
*       BCDE preserved. AF corrupted.
*
PHEX    CALL  :C02D     Convert MACC for hex output
PGP     LHLD  :C033     Get addr DECBUF
        JMP   :DB32     Print string in DECBUF
*
**************************
* PRINT A INTEGER NUMBER *
**************************
*
* Prints an integer number from MACC.
*
PINT    CALL  :DB5F     Convert MACC for output
        JMP   :DB4D     Print contents DECBUF
*
*********************************
* PRINT A FLOATING POINT NUMBER *
*********************************
*
* Prints a FPT number from MACC.
*
PFPT    CALL  :CE9B     Convert MACC for output
        JMP   :DB4D     Print contents DECBUF
*
***************************************
* CONVERT MACC FOR FIXED POINT OUTPUT *
***************************************
*
* Places ASCII-equivalent in 00E4-F0, digits before
* decimal point in 00F1, length in 00E3.
*
* Exit: A: Number of digits.
*       BCDEHL preserved.
*
IBCP    CALL  :C027     Convert INT for output
        PUSH  B
        MVI   B,:00     Can trim last dec. place
BPP     CALL  :C030     Tidy up into external form
        POP   B
        RET
*
********************************
* (Not used, replaced by CE9B) *
********************************
*
LD216   MVI   B,:01     ) Part of a previous version
        JMP   :DB64     )
*
*
        UNL
SCSTM   EQU PSTRM
SCSTR   EQU PSTR
SCTAB   EQU PTAB
        LST
        END
